import request from '../utils/request';
import { type LoginParams, type LoginResponse, } from '../types/auth';
import type { MenuItemType } from '../store/authStore';

/**
 * 用户登录
 * @param params 登录参数
 * @returns 登录结果
 */
export const login = (params: LoginParams): Promise<LoginResponse> => {
    return request.post('/auth/login', params);
};

/**
 * 获取权限菜单和用户信息
 * @returns 权限菜单和用户信息
 */
export const getAuthMenu = (): Promise<MenuItemType[]> => {
    return request.get('/menus');
};

/**
 * 退出登录
 * @returns 退出结果
 */
export const logout = (): Promise<{ success: boolean }> => {
    return request.post('/auth/logout');
};